package com.hanoi.wiki.model.json;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.hanoi.wiki.model.Role;
import com.hanoi.wiki.model.User;
import com.hanoi.wiki.model.UserEvaluation;
import com.hanoi.wiki.model.UserLog;
import com.hanoi.wiki.model.UserStatistic;

public class UserJson extends BaseJsonObject implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private int id;
	private String userName;
	private String password;
	private String right;
	private String description;
	private int status;
	private int userEvaluation;
	private int role;
	private List<Integer> userStatistic;
	private List<Integer> userLog;
	
	public UserJson() {		
		userStatistic = new ArrayList<Integer>();
		userLog = new ArrayList<Integer>();
	}
	
	public UserJson(User user) {
		this();
		if(user != null) {
			this.id = user.getId();
			this.userName = user.getUserName();
			//this.password = user.getPassword();
			this.right = user.getRight();
			this.description = user.getDescription();
			this.status = user.getStatus();
			
			UserEvaluation evaluation = user.getUserEvaluation();
			if(evaluation != null) {
				this.userEvaluation = evaluation.getId();
			}
			
			Role userRole = user.getRole();
			if(userRole != null) {
				this.role = userRole.getId();
			}
			
			for(UserStatistic userStatistic : user.getUserStatistic()) {
				if (userStatistic != null) {
					this.userStatistic.add(userStatistic.getId());
				}
			}
			
			for(UserLog userLog : user.getUserLog()) {
				if (userLog != null) {
					this.userLog.add(userLog.getId());
				}
			}
		}
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getRight() {
		return right;
	}

	public void setRight(String right) {
		this.right = right;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public int getUserEvaluation() {
		return userEvaluation;
	}

	public void setUserEvaluation(int userEvaluation) {
		this.userEvaluation = userEvaluation;
	}

	public List<Integer> getUserStatistic() {
		return userStatistic;
	}

	public void setUserStatistic(List<Integer> userStatistic) {
		this.userStatistic = userStatistic;
	}

	public List<Integer> getUserLog() {
		return userLog;
	}

	public void setUserLog(List<Integer> userLog) {
		this.userLog = userLog;
	}

	public int getRole() {
		return role;
	}

	public void setRole(int role) {
		this.role = role;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	
	
}
